﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BGCOP.CAVTOP.WINFORMS
{
    public partial class frmVisitaProgramadaOk_2 : Form
    {
        public frmVisitaProgramadaOk_2()
        {
            InitializeComponent();
        }

        private void tVisitaProgramadaBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Desea realizar las operaciones pendientes?", Properties.Settings.Default.Titulo,
                MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
            {
                this.Validate();
                this.tVisitaProgramadaBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.masterDBACDataSet);
                MessageBox.Show("El registro se proceso con exito!", Properties.Settings.Default.Titulo
                               , MessageBoxButtons.OK);
            }
        }

        private void frmVisitaProgramadaOk_2_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'masterDBACDataSet.TEmpleado' table. You can move, or remove it, as needed.
            //this.tEmpleadoTableAdapter.Fill(this.masterDBACDataSet.TEmpleado);
            // TODO: This line of code loads data into the 'masterDBACDataSet.TEmpresa' table. You can move, or remove it, as needed.
            this.tEmpresaTableAdapter.Fill(this.masterDBACDataSet.TEmpresa);
            // TODO: This line of code loads data into the 'masterDBACDataSet.TVisitaProgramada' table. You can move, or remove it, as needed.
            this.tVisitaProgramadaTableAdapter.Fill(this.masterDBACDataSet.TVisitaProgramada);

        }

        private void idEmpresaTextBox_TextChanged(object sender, EventArgs e)
        {
            try
            {
                razonSocialComboBox.SelectedValue = Convert.ToInt32(idEmpresaTextBox.Text);
                this.tEmpleadoTableAdapter.FillByEmpleadobyEmpresa(this.masterDBACDataSet.TEmpleado, Convert.ToInt32(idEmpresaTextBox.Text));
            
            }
            catch (Exception)
            {

                razonSocialComboBox.SelectedIndex = -1;
            }
            

        }

        private void idEmpleadoTextBox_TextChanged(object sender, EventArgs e)
        {
            try
            {
                nombreComboBox.SelectedValue = Convert.ToInt32(idEmpleadoTextBox.Text);
            }
            catch (Exception)
            {
                nombreComboBox.SelectedIndex = -1;

            }
        }

        private void razonSocialComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                idEmpresaTextBox.Text = razonSocialComboBox.SelectedValue.ToString();
                this.tEmpleadoTableAdapter.FillByEmpleadobyEmpresa(this.masterDBACDataSet.TEmpleado, Convert.ToInt32(idEmpresaTextBox.Text));
            }
            catch (Exception)
            {
                
                
            }
            
        }

        private void nombreComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                idEmpleadoTextBox.Text = nombreComboBox.SelectedValue.ToString();
                idDivisionEmpresaTextBox.Text = idDivisionEmpresaTextBox1.Text;
            }
            catch (Exception)
            {
                
                
            }
            
        }
        public void centrarPanel()
        {
            //centrar el panel
            panel1.Top = ((this.Height - panel1.Height) / 2);
            panel1.Left = (this.Width - panel1.Width) / 2;
        }

        private void frmVisitaProgramadaOk_2_SizeChanged(object sender, EventArgs e)
        {
            centrarPanel();
        }

        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {

        }

        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            fechaInicioDateTimePicker.Value = DateTime.Now;
            fechafinDateTimePicker.Value = DateTime.Now;
        }
    }
}
